/**
 * 路由配置
 */
import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {HomeComponent} from './home/home.component';
import {ProductComponent} from './product/product.component';
import {Code404Component} from './code404/code404.component';
import {ContentourComponent} from './contentour/contentour.component';
import {ProductdetailComponent} from './productdetail/productdetail.component';
import {ProductdescComponent} from './productdesc/productdesc.component';
import {ProductpackagingComponent} from './productpackaging/productpackaging.component';
import {LoginGuard} from './guard/login.guard';
import {UnsaveGuard} from './guard/unsave.guard';
import {ProductdetailResolve} from './guard/productdetail.resolve';

const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent
  },
  {
    path: '',
    redirectTo: '/home', pathMatch: 'full'
  },
  /*{
    path: 'product',
    component: ProductComponent,
    //canDeactivate: [UnsaveGuard]
  },*/
  {
    path: 'chat',
    component: ProductComponent,
    outlet: 'aux'
  },
  {
    path: 'product/:id',
    component: ProductdetailComponent,
    children: [{
      path: '',
      component: ProductdescComponent
    }, {
      path: 'packaging/:id',
      component: ProductpackagingComponent
    }],
    /*canActivate: [LoginGuard]*/
    resolve: {
      productdetail: ProductdetailResolve
    }
  },
  {
    path: 'contentour',
    component: ContentourComponent
  },
  {
    path: '**',
    component: Code404Component
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: [LoginGuard, UnsaveGuard, ProductdetailResolve]
})

export class AppRoutingModule {
}
